package io.bluerain.javafx.transform;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Shear;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;

/**
 * Created by foredawn on 15-8-28.
 * javafx中的变换效果
 */
public class TransRectangle extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("变换效果测试");

        //创建一个矩形
        Rectangle rect = new Rectangle(200, 100);
        rect.getTransforms().add(new Translate(100, 50));//平移[XYZ]
        rect.getTransforms().add(new Rotate(30, 100, 50));//环转
        rect.getTransforms().add(new Scale(2, 1.5));//缩放
        rect.getTransforms().add(new Shear(0.5, 0));//切变(环转XY轴)


        BorderPane pane = new BorderPane();
        pane.setTop(rect);

        Group root = new Group(pane);
        primaryStage.setScene(new Scene(root, 300, 300));
        primaryStage.show();
    }


}
